import os
from dashscope import Generation




def main():
    msgs = [{"role": "user", "content": "我是奶龙，我是个小cs，我喜欢吃鲱鱼罐头"}]

    response = Generation.call(
        api_key = os.getenv("DASHSCOPE_API_KEY"),
        model = "qwen-turbo",
        messages = msgs,
        result_format = "message"
    )
    if response.status_code == 200:
        print(response.output.choices[0].message.content)
        msgs.append({"role": response.output.choices[0].message.role,
                     "content": response.output.choices[0].message.content})
    else:
        print(response.status_code)
        print(response.message)
    msgs = [{"role": "user", "content": "你是谁"}]
    response = Generation.call(
        api_key = os.getenv("DASHSCOPE_API_KEY"),
        model = "qwen-turbo",
        messages = msgs,
        result_format = "message"
    )
    if response.status_code == 200:
        print(response.output.choices[0].message.content)
    else:
        print(response.status_code)
        print(response.message)
if __name__ == '__main__':
    main()